package bTree.LeetCode;

import static java.lang.Math.min;

public class 最长公共前缀 {
    public String longestCommonPrefix(String[] strs) {
        if(strs.length==0){
            return "";
        }
        String s=strs[0];
        int index=1;
        while (index<=s.length()) {
            String commen=s.substring(0,index);
            for(String str:strs){
                if(!str.startsWith(commen)){
                    return commen.substring(0,index-1);
                }

            }
            index++;
        }
        return s;
    }
}